from selenium import webdriver

from base.get_logger import GetLogger

logger = GetLogger().get_logger()

class GetDriver:
    driver = None
    @classmethod
    def get_driver(cls,url):
        logger.info("正在初始化driver")
        try:
            if cls.driver is None:
                cls.driver = webdriver.Firefox()
                cls.driver.maximize_window()
                cls.driver.get(url)
            return cls.driver
        except Exception as e:
            logger.error(e)

    @classmethod
    def quit_driver(cls):
        logger.info("正在退出driver")
        if cls.driver:
            cls.driver.quit()
            cls.driver = None